
    <!DOCTYPE html>
    <html lang="zh-CN">
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>SQL映射与XML解析 - 学习卡片</title>
      <style>
        body { font-family: sans-serif; background-color: #f0f8ff; color: #333; display: flex; flex-direction: column; align-items: center; padding: 50px 20px; }
        .header h1 { font-size: 32px; }
        .grid-container { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; width: 100%; max-width: 1200px; }
        .card-container { perspective: 1200px; cursor: pointer; height: 250px; }
        .card { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transition: transform 0.7s; border-radius: 16px; box-shadow: 0 4px 16px rgba(0,0,0,0.08); }
        .card-container.flipped .card { transform: rotateY(180deg); }
        .card-face { position: absolute; width: 100%; height: 100%; backface-visibility: hidden; display: flex; flex-direction: column; box-sizing: border-box; border-radius: 16px; background-color: #fff; padding: 24px; }
        .card-back { background-color: #f0fff4; transform: rotateY(180deg); justify-content: space-between; }
        .card-category { font-size: 14px; color: #0052d9; margin-bottom: 8px; font-weight: 500; }
        .card-question { font-size: 20px; font-weight: 500; flex-grow: 1; display: flex; align-items: center; justify-content: center; text-align: center; }
        .card-answer-wrapper { flex-grow: 1; overflow-y: auto; }
        .card-answer { font-size: 15px; line-height: 1.7; }
        .card-footer { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 16px; margin-top: 16px; }
        .card-source { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 12px; margin-top: 12px; }
      </style>
    </head>
    <body>
      <div class="header">
        <h1>SQL映射与XML解析 - 学习卡片</h1>
      </div>
      <div class="grid-container">
        
    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">理论</div>
          <div class="card-question">MyBatis中的SQL映射核心作用是什么？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">理论</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">SQL映射是MyBatis的核心功能之一，它通过XML文件配置SQL语句，并在Java代码中执行映射操作。其主要作用是在Java对象与数据库表之间进行灵活的转换。</div>
          </div>
          <div class="card-source">来源: 1. SQL映射的作用与基础概念</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">在MyBatis中，`SqlSessionFactory`是如何通过解析配置文件创建的？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">创建`SqlSessionFactory`时，会首先创建一个`XMLConfigBuilder`实例来解析MyBatis的全局XML配置文件。解析完成后会生成一个`Configuration`对象，该对象包含了所有配置信息，最后基于这个`Configuration`对象创建`DefaultSqlSessionFactory`实例。</div>
          </div>
          <div class="card-source">来源: 2. `SqlSession`的初始化过程</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">哪个类负责解析 `Mapper.xml` 文件，并将文件中的SQL标签转换成什么对象？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">`XMLMapperBuilder`类负责解析`Mapper.xml`文件。它会将文件中的每一个SQL语句标签（如`<select>`, `<insert>`等）转换成相应的`MappedStatement`对象。</div>
          </div>
          <div class="card-source">来源: 4. `Mapper.xml`中SQL映射语句的解析</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">理论</div>
          <div class="card-question">请解释MyBatis中的 `MappedStatement` 对象是什么，它包含了哪些重要信息？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">理论</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">`MappedStatement`是MyBatis映射SQL语句的核心对象。它包含了SQL语句、参数类型、返回类型以及如何执行该SQL语句的配置信息（例如通过哪个`Executor`执行）。</div>
          </div>
          <div class="card-source">来源: 5. `MappedStatement`的构建</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">在MyBatis中，`Executor` 的角色和工作流程是怎样的？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">`Executor`是MyBatis的核心执行器，负责执行SQL语句并返回结果。`SqlSession`通过调用`Executor`的`query()`等方法来执行数据库操作。`Executor`会根据`MappedStatement`获取`BoundSql`对象，然后将SQL语句传递给JDBC执行，并处理结果映射。</div>
          </div>
          <div class="card-source">来源: 6. `Executor`的工作流程</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">MyBatis使用哪个对象来封装最终要执行的、已绑定参数的SQL语句？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">MyBatis使用 `BoundSql` 对象来封装SQL语句。它包含了最终执行的SQL语句和相关的参数，是参数绑定后的结果。</div>
          </div>
          <div class="card-source">来源: 6. `Executor`的工作流程 & 7. SQL语句的参数绑定</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">在MyBatis的初始化过程中，`XMLConfigBuilder`类的主要职责是什么？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">`XMLConfigBuilder`是用于解析配置文件的核心类，其主要职责是解析MyBatis的全局配置文件（如`mybatis-config.xml`），并将XML中的内容转换为一个包含了所有配置信息的`Configuration`对象。</div>
          </div>
          <div class="card-source">来源: 3. `XMLConfigBuilder`与XML解析</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">理论</div>
          <div class="card-question">MyBatis中的`Configuration`对象是如何产生的，它包含了哪些内容？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">理论</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">`Configuration`对象是由`XMLConfigBuilder`解析全局配置文件（如`mybatis-config.xml`）后转化而来的。它包含了MyBatis框架的所有配置信息，包括SQL映射的XML配置。</div>
          </div>
          <div class="card-source">来源: 2. `SqlSession`的初始化过程</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">请根据文档，总结MyBatis从XML解析到SQL执行的三个核心步骤。</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">1. 配置加载与解析：MyBatis通过`XMLConfigBuilder`加载全局配置文件并解析出数据库连接信息和映射配置。 2. Mapper文件解析：通过`XMLMapperBuilder`解析`Mapper.xml`文件，将SQL映射语句转化为`MappedStatement`。 3. SQL执行：`SqlSession`通过`Executor`执行SQL，并将查询结果返回给用户。</div>
          </div>
          <div class="card-source">来源: 8. XML解析与SQL执行的整体流程总结</div>
        </div>
      </div>
    </div>

      </div>
    </body>
    </html>
